import axios from "axios";
import { showLoadingToast, closeToast } from 'vant';
// Add a request interceptor
axios.interceptors.request.use(function (config) {
    // Do something before request is sent
    let token = localStorage.getItem('token')
    if (token) {
        config.headers.Authorizatiotoken
    }
    showLoadingToast({
        duration: 3000,
        forbidClick: true,
        message: '加载中',
    });

    return config;
}, function (error) {
    closeToast();
    // Do something with request error
    return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
    closeToast();
    // Any status code that lie within the range of 2xx cause this function to trigger
    // Do something with response data
    return response;
}, function (error) {
    closeToast();
    // Any status codes that falls outside the range of 2xx cause this function to trigger
    // Do something with response error
    return Promise.reject(error);
});
export default axios